/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Views.Base;

import Views.*;
import java.awt.Dimension;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

/**
 *
 * @author Joshua King
 */
public abstract class BaseViewCreateUser extends JPanel {
    private static int maxChar = 10;
    protected ViewMain mainView;
    private JPanel userPanel = new JPanel();
    private JPanel passwordPanel = new JPanel();
    private JPanel confirmPasswordPanel = new JPanel();
    private JPanel firstNamePanel = new JPanel();
    private JPanel lastNamePanel = new JPanel();
    private JPanel addressPanel = new JPanel();
    private JLabel userLabel = new JLabel("Name: ");
    private JLabel passwordLabel = new JLabel("Password: ");  
    private JLabel confirmPasswordLabel = new JLabel("Retype Password: ");  
    private JLabel firstNameLabel = new JLabel("First Name: ");
    private JLabel lastNameLabel = new JLabel("Last Name: ");
    private JLabel addressLabel = new JLabel("Address: ");
    protected JTextField user = new JTextField(maxChar);
    protected JPasswordField password = new JPasswordField(maxChar);
    protected JPasswordField confirmPassword = new JPasswordField(maxChar);
    protected JTextField firstName = new JTextField(maxChar);
    protected JTextField lastName = new JTextField(maxChar);
    protected JTextField address = new JTextField(maxChar);
    protected JButton createUserButton = new JButton("Create User");
    
    /**
     * public constructor that initialises the view
     * @param view
     */
    public BaseViewCreateUser() {
        this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
        this.add(userPanel);
        this.add(passwordPanel);
        this.add(confirmPasswordPanel);
        this.add(firstNamePanel);
        this.add(lastNamePanel);
        this.add(addressPanel);
        this.add(createUserButton);
        this.add(Box.createRigidArea(new Dimension(100,320)));
        this.setVisible(true);
        
        userPanel.setLayout(new BoxLayout(userPanel, BoxLayout.LINE_AXIS));
        userPanel.setAlignmentX(CENTER_ALIGNMENT);  
        userPanel.add(userLabel);
        userPanel.add(user);
        
        userLabel.setAlignmentY(TOP_ALIGNMENT);
        user.setAlignmentY(TOP_ALIGNMENT);

        
        passwordPanel.setLayout(new BoxLayout(passwordPanel, BoxLayout.LINE_AXIS));
        passwordPanel.setAlignmentX(CENTER_ALIGNMENT);
        passwordPanel.add(passwordLabel);
        passwordPanel.add(password);
        password.setEchoChar('*');
        
        confirmPasswordPanel.setLayout(new BoxLayout(confirmPasswordPanel, BoxLayout.LINE_AXIS));
        confirmPasswordPanel.setAlignmentX(CENTER_ALIGNMENT); 
        confirmPasswordPanel.add(confirmPasswordLabel);
        confirmPasswordPanel.add(confirmPassword);
        confirmPassword.setEchoChar('*');
        
        firstNamePanel.setLayout(new BoxLayout(firstNamePanel, BoxLayout.LINE_AXIS));
        firstNamePanel.setAlignmentX(CENTER_ALIGNMENT); 
        firstNamePanel.add(firstNameLabel);
        firstNamePanel.add(firstName);
        
        
        lastNamePanel.setLayout(new BoxLayout(lastNamePanel, BoxLayout.LINE_AXIS));
        lastNamePanel.setAlignmentX(CENTER_ALIGNMENT);
        lastNamePanel.add(lastNameLabel);
        lastNamePanel.add(lastName);
        
        addressPanel.setLayout(new BoxLayout(addressPanel, BoxLayout.LINE_AXIS));
        addressPanel.setAlignmentX(CENTER_ALIGNMENT);
        addressPanel.add(addressLabel);
        addressPanel.add(address);        
    }
}
